Skip to content

Fix progress bar byte count for multibyte encodings (e.g. utf-16-le)#810

Open
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-progress-bar-utf16-byte-count
Open

Fix progress bar byte count for multibyte encodings (e.g. utf-16-le)#810
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-progress-bar-utf16-byte-count

Conversation

@ikatyal2110

@ikatyal2110 ikatyal2110 commented Jul 22, 2026

Copy link
Copy Markdown

UpdateWrapper.iter and .read() called len() on decoded text strings, but the progress bar total is set from os.path.getsize() which returns raw bytes. For multibyte encodings like utf-16-le each character is 2 bytes, so the bar would only reach ~50% before the insert finished. This fix encodes each string back with the file's encoding before measuring length so the byte counts match. Fixes #439


Generated by Claude Code


📚 Documentation preview 📚: https://sqlite-utils--810.org.readthedocs.build/en/810/

…multibyte encodings

UpdateWrapper.__iter__ and .read() used len(line) which counts decoded characters,
but the progress bar total comes from os.path.getsize() (raw bytes). For encodings
like utf-16-le each character is 2 bytes, so the bar would only reach ~50%. Encode
the string back with the file's encoding to get the correct byte length.

Fixes simonw#439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading progress bar against utf-16-le CSV input

2 participants